﻿<template>
    <div id="wrapper">

        <el-form :model="data" label-width="150px" style="padding: 20px 0px" ref="Engineering">
            <el-row>
                <el-col :span="20" :offset="1">
                    <el-form-item label="开票已收款金额" prop="ApplyUserid">
                        <el-input type="text" id="CollectionAmount" v-model="data.CollectionAmount" />
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row>
                <el-col :span="10" :offset="1">
                    <el-form-item label="结算金额" prop="ApplyUserid">
                        <el-input type="text" id="SettleMoney" name="SettleMoney" v-model="data.SettleMoney" />
                    </el-form-item>
                </el-col>
                <el-col :span="10"  >
                    <el-form-item label="冲销税额" prop="ApplyUserid">
                        <el-input type="text" id="WriteOffTax" name="WriteOffTax" v-model="data.WriteOffTax" />
                    </el-form-item>
                </el-col>
            </el-row>



            <el-row> 
                <el-col :span="10" :offset="1">
                    <el-form-item label="坏账金额" prop="ApplyUserid">
                        <el-input type="text" id="BadMoney" name="BadMoney" v-model="data.BadMoney" />
                    </el-form-item>
                </el-col>
               <el-col :span="10" >
                    <el-form-item label="个人借款" prop="ApplyUserid">
                        <el-input type="text" id="PersonLoan" name="PersonLoan" v-model="data.PersonLoan" />
                    </el-form-item>
                </el-col>
            </el-row>


            <el-row>
                <el-col :span="10" :offset="1">
                    <el-form-item label="采购未到票" prop="ApplyUserid">
                        <el-input type="text" id="PurchaseCost" name="PurchaseCost" v-model="data.PurchaseCost" />
                    </el-form-item>
                </el-col>
               <el-col :span="10" >
                    <el-form-item label="人工费" prop="ApplyUserid">
                        <el-input type="text" id="LaborCost" name="LaborCost" v-model="data.LaborCost" />
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row>
                <el-col :span="10" :offset="1">
                    <el-form-item label="材料费" prop="ApplyUserid">
                        <el-input type="text" id="MaterialCost" name="MaterialCost" v-model="data.MaterialCost" />
                    </el-form-item>
                </el-col>
               <el-col :span="10" >
                    <el-form-item label="机械使用费" prop="ApplyUserid">
                        <el-input type="text" id="MachineryCost" name="MachineryCost" v-model="data.MachineryCost" />
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row>
                <el-col :span="10" :offset="1">
                    <el-form-item label="其它直接费" prop="ApplyUserid">
                        <el-input type="text" id="OtherDirectCost" name="OtherDirectCost" v-model="data.OtherDirectCost" />
                    </el-form-item>
                </el-col>
               <el-col :span="10" >
                    <el-form-item label="分包成本" prop="ApplyUserid">
                        <el-input type="text" id="SubcontractingCost" name="SubcontractingCost" v-model="data.SubcontractingCost" />
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row>
                <el-col :span="10" :offset="1">
                    <el-form-item label="冲销后增值税费用" prop="ApplyUserid">
                        <el-input type="text" id="WriteOffRate" name="WriteOffRate" v-model="data.WriteOffRate" />
                    </el-form-item>
                </el-col>
               <el-col :span="10" >
                    <el-form-item label="管理人员费用" prop="ApplyUserid">
                        <el-input type="text" id="ManagementPersonCost" name="ManagementPersonCost" v-model="data.ManagementPersonCost" />
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row>
                <el-col :span="10" :offset="1">
                    <el-form-item label="福利费" prop="ApplyUserid">
                        <el-input type="text" id="WelfareCost" name="WelfareCost" v-model="data.WelfareCost" />
                    </el-form-item>
                </el-col>
               <el-col :span="10" >
                    <el-form-item label="固定资产使用费" prop="ApplyUserid">
                        <el-input type="text" id="FixedAssetsCost" name="FixedAssetsCost" v-model="data.FixedAssetsCost" />
                    </el-form-item>
                </el-col>
            </el-row>



            <el-row>
                <el-col :span="10" :offset="1">
                    <el-form-item label="低值易耗品摊销" prop="ApplyUserid">
                        <el-input type="text" id="LowValueCost" name="LowValueCost" v-model="data.LowValueCost" />
                    </el-form-item>
                </el-col>
               <el-col :span="10" >
                    <el-form-item label="办公费" prop="ApplyUserid">
                        <el-input type="text" id="OfficeCost" name="OfficeCost" v-model="data.OfficeCost" />
                    </el-form-item>
                </el-col>
            </el-row>


            <el-row>
                <el-col :span="10" :offset="1">
                    <el-form-item label="差旅费" prop="ApplyUserid">
                        <el-input type="text" id="TravelCost" name="TravelCost" v-model="data.TravelCost" />
                    </el-form-item>
                </el-col>
               <el-col :span="10" >
                    <el-form-item label="业务招待费" prop="ApplyUserid">
                        <el-input type="text" id="BusinessCost" name="BusinessCost" v-model="data.BusinessCost" />
                    </el-form-item>
                </el-col>
            </el-row>


            <el-row>
                <el-col :span="10" :offset="1">
                    <el-form-item label="安全保护费" prop="ApplyUserid">
                        <el-input type="text" id="SafetyCost" name="SafetyCost" v-model="data.SafetyCost" />
                    </el-form-item>
                </el-col>
               <el-col :span="10" >
                    <el-form-item label="车辆使用费" prop="ApplyUserid">
                        <el-input type="text" id="VehicleCost" name="VehicleCost" v-model="data.VehicleCost" />
                    </el-form-item>
                </el-col>
            </el-row>


            <el-row>
                <el-col :span="10" :offset="1">
                    <el-form-item label="其它间接费用" prop="ApplyUserid">
                        <el-input type="text" id="OtherIndirectCost" name="OtherIndirectCost" v-model="data.OtherIndirectCost" />

                    </el-form-item>
                </el-col>
               <el-col :span="10" >
                    <el-form-item label="经营费用" prop="ApplyUserid">
                        <el-input type="text" id="OperatingCost" name="OperatingCost" v-model="data.OperatingCost" />
                    </el-form-item>
                </el-col>
            </el-row>

        </el-form>

        <div style="text-align:center">

            <el-button type="success" @click="AddSubmit">项目财务</el-button>
        </div>
    </div>
</template>

<script>
    export default {
        name: "ProjectFinance",
        props: {
            project: {
                type: Object,
                required: true,
            },
        },
        data() {
            return {
                data: {
                    Id: 0,
                    CollectionAmount: 0,
                    BadMoney: 0,
                    WriteOffTax: 0,
                    SettleMoney: 0,
                    PersonLoan: 0,
                    PurchaseCost: 0,
                    LaborCost: 0,
                    MaterialCost: 0,
                    MachineryCost: 0,
                    OtherDirectCost: 0,
                    SubcontractingCost: 0,
                    WriteOffRate: 0,
                    ManagementPersonCost: 0,
                    WelfareCost: 0,
                    FixedAssetsCost: 0,
                    LowValueCost: 0,
                    OfficeCost: 0,
                    TravelCost: 0,
                    BusinessCost: 0,
                    SafetyCost: 0,
                    VehicleCost: 0,
                    OtherIndirectCost: 0,
                    OperatingCost: 0,
                }
            }
        },
        watch: {
            project: function (val) {
                this.GetAllData(val);
            }
        },
        mounted() {
            let _this = this
            _this.$nextTick(() => {
                _this.GetAllData(_this.project);
            })
        }, 
        methods: {
            //获取数据
            GetAllData() {
                let loadding = this.openLoading("数据加载中...");
                this.$http.post("/Project1/GetAllProjectFinanceData", { id: this.project.Id }).then(res => {
                    loadding.close();
                    this.InitData(res.data.pro);
                }).catch(() => {
                    loadding.close();
                    this.$message.error('服务器异常,请联系管理员!')
                }) 

            }
            , AddSubmit() {
                let loadding = this.openLoading("数据提交中..."); 
                let _this = this;
                this.$http.post("/Project1/UpdateProjectFinance", { project: this.data }).then(res => {
                    loadding.close();
                    console.log(res.data.mess)
                    var data = res.data.mess;
                    if (data.IsRedirect) {
                        _this.$message.success(data.Msg)
                    } else {
                        _this.$message.error(data.Msg)
                    }
                }).catch(() => {
                    loadding.close();
                    this.$message.error('服务器异常,请联系管理员!')
                }) 
                return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            }
            , InitData(data) {
                this.data.project = data.pro;
                this.data.Id = data.Id;
                this.data.CollectionAmount = data.CollectionAmount;
                this.data.BadMoney = data.BadMoney;
                this.data.WriteOffTax = data.WriteOffTax;
                this.data.SettleMoney = data.SettleMoney;
                this.data.PersonLoan = data.PersonLoan;
                this.data.PurchaseCost = data.PurchaseCost;
                this.data.LaborCost = data.LaborCost;
                this.data.MaterialCost = data.MaterialCost;
                this.data.MachineryCost = data.MachineryCost;
                this.data.OtherDirectCost = data.OtherDirectCost;
                this.data.SubcontractingCost = data.SubcontractingCost;
                this.data.WriteOffRate = data.WriteOffRate;
                this.data.ManagementPersonCost = data.ManagementPersonCost;
                this.data.WelfareCost = data.WelfareCost;
                this.data.FixedAssetsCost = data.FixedAssetsCost;
                this.data.LowValueCost = data.LowValueCost;
                this.data.OfficeCost = data.OfficeCost;
                this.data.TravelCost = data.TravelCost;
                this.data.BusinessCost = data.BusinessCost;
                this.data.SafetyCost = data.SafetyCost;
                this.data.VehicleCost = data.VehicleCost;
                this.data.OtherIndirectCost = data.OtherIndirectCost;
                this.data.OperatingCost = data.OperatingCost;
            },
        },
    }
</script>

<style scoped>
</style>
